<template>
  <div class="feedback-container">
    <!-- 背景装饰 -->
    <div class="background-decoration"></div>

    <!-- 主要内容区域 -->
    <div class="feedback-content">
      <!-- 左侧评分区域 -->
      <div class="rating-section">
        <div class="section-header">
          <h3 class="section-title">满意度评价</h3>
          <p class="section-subtitle">请为以下各项进行评分</p>
        </div>
        <div class="form-wrapper">
          <el-form label-width="180px" class="rating-form">
            <el-form-item label="面试过程满意度" class="rating-item">
              <el-rate v-model="ratings.interviewProcess" :colors="rateColors" show-score/>
            </el-form-item>
            <el-form-item label="界面指引清晰度" class="rating-item">
              <el-rate v-model="ratings.interfaceClarity" :colors="rateColors" show-score/>
            </el-form-item>
            <el-form-item label="视觉效果满意度" class="rating-item">
              <el-rate v-model="ratings.visualEffect" :colors="rateColors" show-score/>
            </el-form-item>
            <el-form-item label="面试过程流畅度" class="rating-item">
              <el-rate v-model="ratings.processSmoothness" :colors="rateColors" show-score/>
            </el-form-item>
            <el-form-item label="AI回复满意度" class="rating-item">
              <el-rate v-model="ratings.aiResponse" :colors="rateColors" show-score/>
            </el-form-item>
            <el-form-item label="功能多样性" class="rating-item">
              <el-rate v-model="ratings.featureDiversity" :colors="rateColors" show-score/>
            </el-form-item>
            <el-form-item label="报告满意度" class="rating-item">
              <el-rate v-model="ratings.reportSatisfaction" :colors="rateColors" show-score/>
            </el-form-item>
            <el-form-item label="整体满意度" class="rating-item">
              <el-rate v-model="ratings.overallSatisfaction" :colors="rateColors" show-score/>
            </el-form-item>
          </el-form>
        </div>
      </div>

      <!-- 右侧文本反馈区域 -->
      <div class="feedback-section">
        <div class="section-header">
          <h3 class="section-title">意见建议</h3>
          <p class="section-subtitle">有什么话想对我们说</p>
        </div>

        <div class="textarea-wrapper">
          <textarea
              v-model="feedbackText"
              class="feedback-textarea"
              placeholder="请输入您的意见和建议，我们会认真对待每一条反馈..."
              @focus="handleFocus"
              @blur="handleBlur"
          />
          <div class="textarea-footer">
            <span class="char-count">{{ feedbackText.length }}/200</span>
          </div>
        </div>
        <!-- 提交按钮区域 -->
        <div class="submit-section">
          <el-button type="primary" class="submit-btn" @click="handleSubmit" size="large">
            <span class="submit-text">提交反馈</span>
          </el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import {ElMessage} from "element-plus";

// 评分项初始化
const ratings = ref({
  interviewProcess: 5,
  interfaceClarity: 5,
  visualEffect: 5,
  processSmoothness: 5,
  aiResponse: 5,
  featureDiversity: 5,
  reportSatisfaction: 5,
  overallSatisfaction: 5
})

const feedbackText = ref('')
// 五星制评分颜色（从低到高评分依次对应颜色）
const rateColors = [
  '#ff6b6b', '#ff9f43', '#feca57',
];

const handleSubmit = () => {
  ElMessage.success('感谢您的反馈！')
}

const handleFocus = (event) => {
  event.target.style.borderColor = '#667eea'
  event.target.style.boxShadow = '0 0 20px rgba(102, 126, 234, 0.3)'
  event.target.style.transform = 'translateY(-2px)'
}

const handleBlur = (event) => {
  event.target.style.borderColor = '#e1e8ed'
  event.target.style.boxShadow = '0 8px 25px rgba(0, 0, 0, 0.08)'
  event.target.style.transform = 'translateY(0)'
}
</script>

<style lang="scss" scoped>
/* 添加滑入动画关键帧 */
@keyframes slideInFromBottom {
  0% {
    transform: translateY(100px);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.feedback-container {
  padding: 40px 20px;
  position: relative;
  overflow: hidden;
  /* 添加动画效果 */
  animation: slideInFromBottom 0.4s ease-out forwards;
}

.background-decoration {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.header-section {
  text-align: center;
  margin-bottom: 40px;
  position: relative;
  z-index: 1;
}

.main-title {
  font-size: 32px;
  font-weight: 700;
  color: white;
  margin-bottom: 10px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.description {
  color: rgba(255, 255, 255, 0.9);
  font-size: 16px;
  margin: 0;
}

.feedback-content {
  display: flex;
  gap: 30px;
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* 为左右两个区域添加错开的动画延迟 */
.rating-section,
.feedback-section {
  flex: 1;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  /* 添加动画效果 */
  opacity: 0;
  animation: slideInFromBottom 0.4s ease-out forwards;
}

/* 左侧评分区域动画延迟 */
.rating-section {
  animation-delay: 0.2s;
}

/* 右侧反馈区域动画延迟 */
.feedback-section {
  animation-delay: 0.2s;
}

.rating-section:hover,
.feedback-section:hover {
  transform: translateY(-5px);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
}

.section-header {
  margin-bottom: 25px;
  text-align: center;
}

.section-title {
  font-size: 26px;
  font-weight: 600;
  color: #2d3748;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.section-subtitle {
  color: #718096;
  font-size: 16px;
  margin: 0;
}

.form-wrapper {
  display: flex;
  justify-content: center; /* 水平居中 */
  align-items: center;      /* 垂直居中 */
  height: 80%;             /* 确保容器有高度 */
}

.rating-form {
  background: transparent;
  padding: 0;
  box-shadow: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

/* 为每个评分项添加交错动画 */
.rating-item {
  margin-bottom: 20px;
  padding: 15px;
  background: rgba(248, 250, 252, 0.8);
  border-radius: 12px;
  transition: all 0.3s ease;
  border: 1px solid rgba(226, 232, 240, 0.5);
  opacity: 0;
  animation: slideInFromBottom 0.2s ease-out forwards;
}

/* 为每个评分项添加递增的动画延迟 */
.rating-item:nth-child(1) { animation-delay: 0.2s; }
.rating-item:nth-child(2) { animation-delay: 0.3s; }
.rating-item:nth-child(3) { animation-delay: 0.4s; }
.rating-item:nth-child(4) { animation-delay: 0.5s; }
.rating-item:nth-child(5) { animation-delay: 0.6s; }
.rating-item:nth-child(6) { animation-delay: 0.7s; }
.rating-item:nth-child(7) { animation-delay: 0.8s; }
.rating-item:nth-child(8) { animation-delay: 0.9s; }

.rating-item:hover {
  background: rgba(241, 245, 249, 0.9);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(148, 163, 184, 0.15);
}

:deep(.el-form-item__label) {
  font-size: 18px;
  font-weight: 500;
  color: #4a5568;
}

:deep(.el-rate__icon) {
  font-size: 30px;
  width: 30px;
  height: 30px;
  margin-right: 8px;
}

:deep(.el-rate__text) {
  color: #667eea;
  font-weight: 600;
  margin-left: 10px;
}

.textarea-wrapper {
  position: relative;
  user-select: none;
  /* 添加动画效果 */
  opacity: 0;
  animation: slideInFromBottom 0.2s ease-out forwards;
  animation-delay: 0.6s;
}

.feedback-textarea {
  width: 100%;
  height: 300px;
  padding: 20px;
  font-size: 16px;
  border: 2px solid #e1e8ed;
  border-radius: 15px;
  outline: none;
  resize: none;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  transition: all 0.3s ease;
  background: rgba(255, 255, 255, 0.9);
}

.feedback-textarea::placeholder {
  color: #a0aec0;
  font-style: italic;
}

.textarea-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.char-count {
  color: #718096;
  font-size: 12px;
}

.submit-section {
  text-align: center;
  margin-top: 40px;
  position: relative;
  z-index: 1;
  /* 添加动画效果 */
  opacity: 0;
  animation: slideInFromBottom 0.7s ease-out forwards;
  animation-delay: 0.8s;
}

.submit-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 50px;
  padding: 15px 50px;
  font-size: 18px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.submit-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 40px rgba(102, 126, 234, 0.6);
}

.submit-btn:active {
  transform: translateY(-1px);
}

.submit-text {
  position: relative;
  z-index: 1;
}

:deep(.el-form-item) {
  margin-bottom: 0;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .feedback-content {
    flex-direction: column;
    gap: 20px;
  }

  .main-title {
    font-size: 24px;
  }

  .rating-section,
  .feedback-section {
    padding: 20px;
  }

  .feedback-textarea {
    height: 200px;
  }

  .rating-form {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}
</style>